//
//  ShopView.m
//  shop
//
//  Created by Justsoso on 16/2/28.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ShopView.h"

#import "Shop.h"

@interface ShopView()

@property (nonatomic,strong) UIImageView *pictureView;
@property (nonatomic,strong) UILabel *alreadyCountLabel;
@property (nonatomic,strong) UILabel *totalCount;
@property (nonatomic,strong) UIButton *shoppingCart;

@end
@implementation ShopView

- (UIImageView *)pictureView
{
    if (_pictureView == nil)
    {
        UIImageView *imageView = [[UIImageView alloc] init];
        [self addSubview:imageView];
        _pictureView = imageView;
    }
    return _pictureView;
}

- (UILabel *)alreadyCountLabel
{
    if (_alreadyCountLabel == nil)
    {
        UILabel *label = [[UILabel alloc] init];
        label.font = [UIFont systemFontOfSize:13];
        label.textAlignment = NSTextAlignmentLeft;
        label.textColor = [UIColor grayColor];
        [self addSubview:label];
        _alreadyCountLabel = label;
    }
    return _alreadyCountLabel;
}

- (UILabel *)totalCount
{
    if (_totalCount == nil)
    {
        UILabel *label = [[UILabel alloc] init];
        label.font = [UIFont systemFontOfSize:15];
        label.textAlignment = NSTextAlignmentLeft;
        [self addSubview:label];
        _totalCount = label;
    }
    return _totalCount;
}

- (UIButton *)shoppingCart
{
    if (_shoppingCart == nil)
    {
        UIButton *btn = [[UIButton alloc] init];
        [self addSubview:btn];
        _shoppingCart = btn;
    }
    return _shoppingCart;
}

- (void)layoutSubviews
{
    int width = self.frame.size.width;
    int height = self.frame.size.height;
    
    self.pictureView.frame = CGRectMake(0, 0, width, height-40);
    self.totalCount.frame = CGRectMake(5, height-40, width-40, 20);
    self.alreadyCountLabel.frame = CGRectMake(5, height-20, width-40, 20);
    self.shoppingCart.frame = CGRectMake(width-40, height-40, 40, 40);
    
    
}

- (void)setShop:(Shop *)shop
{
    _shop = shop;
    
    self.pictureView.image = [UIImage imageNamed:_shop.picture];
    self.totalCount.text = [@"总需人数:" stringByAppendingString:_shop.totalCount];
    self.alreadyCountLabel.text = [@"参与:" stringByAppendingString:_shop.alreadyCount];
    [self.shoppingCart setImage:[UIImage imageNamed:@"tfw_gwc"] forState:UIControlStateNormal];
    
}

@end



















